import request from '@/common/utils/request'
import type { DataItem, PostSysRole } from '@/common/types/role-type'

/**
 * 获取-已启动的角色列表
 * @returns
 */
export const getSysRoleListEnabledApi = () => {
    return request({
        url: '/sys/role/list/enabled',
        method: 'GET'
    })
}


/**
 * 获取-获取角色列表
 * @returns
 */
export const getStyRoleApi = (params) => {
    return request({
        url: '/sys/role',
        method: 'GET',
        params
    })
}


/**
 * 获取-角色详情
 * @returns
 */
export const getSysRoleIdApi = (id: string) => {
    return request({
        url: `/sys/role/${id}`,
        method: 'GET'
    })
}


/**
 * 编辑-角色
 * @returns
 */
export const putSysRoleIdApi = (data: DataItem) => {
    return request({
        url: `/sys/role/${data.id}`,
        method: 'PUT',
        data
    })
}

/**
 * 新增-角色
 * @returns
 */
export const postSysRoleApi = (data: PostSysRole) => {
    return request({
        url: '/sys/role',
        method: 'POST',
        data
    })
}


/**
 * 分配权限-角色
 * @returns
 */
export const putSysRoleAssignPremApi = (data: any[]) => {
    return request({
        url: '/sys/role/assignPrem',
        method: 'PUT',
        data
    })
}

/**
 * 删除-角色
 * @returns
 */
export const deleteSysRoleIdApi = (id: string) => {
    return request({
        url: `/sys/role/${id}`,
        method: 'DELETE',
    })
}